package com.example.demoss.service.impl;

import com.example.demoss.entity.Dec;
import com.example.demoss.service.IndexService;
import com.example.demoss.util.AqiDictionaryUtil;
import com.example.demoss.util.MapUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.concurrent.CompletableFuture;

/**
 * @author 黄靖
 * @author 2022-11-30 17:01
 * description:
 **/
@Slf4j
@Service
public class IndexServiceImpl implements IndexService {
    @Override
    public double excuteThree(Dec dec) {
        final double pm_2_5  = excuteThreee(AqiDictionaryUtil.pm2_5Map, dec.getPm25());

        final double co = excuteThreee(AqiDictionaryUtil.coMap,dec.getCo());



        final double no2 = excuteThreee(AqiDictionaryUtil.no2Map, dec.getNo2());





        final double o3 = excuteThreee(AqiDictionaryUtil.o3Map, dec.getO3());


        final double so2 = excuteThreee(AqiDictionaryUtil.so2Map, dec.getSo2());


        final double maxone = Math.max(pm_2_5, co);
        final double maxtwo = Math.max(no2, o3);
        final double maxthree = Math.max(maxone, maxtwo);
        final double max = Math.max(maxthree, so2);

        return max;
    }

    @Override
    public double excuteFour(Dec dec) {
        final double pm_2_5  = excutefour(AqiDictionaryUtil.pm2_5Map, dec.getPm25());
        //  log.info("算出的 pm2.5 ======>{}",pm_2_5);
        final double co = excutefour(AqiDictionaryUtil.coMap,dec.getCo());
        //  log.info("算出的 co ========>{}",co);
        final double no2 = excutefour(AqiDictionaryUtil.no2Map, dec.getNo2());

        //   log.info("算出的 no2 ========>{}",no2);
        final double o3 = excutefour(AqiDictionaryUtil.o3Map, dec.getO3());

        //   log.info("算出的 o3 ========>{}",o3);
        final double so2 = excutefour(AqiDictionaryUtil.so2Map, dec.getSo2());

        //   log.info("算出的 so2 ========>{}",so2);

        final double maxone = Math.max(pm_2_5, co);
        final double maxtwo = Math.max(no2, o3);
        final double maxthree = Math.max(maxone, maxtwo);
        final double max = Math.max(maxthree, so2);

        return max;
    }

    public String areaOne(Dec dec){
        String city =areaTestOne(dec.getLat(),dec.getLon());
        return city;
    }

    public String areaTwo(Dec dec){
        return areaTestTwo(dec.getLat(),dec.getLon());
    }

    public String areaThree(Dec dec){
        return areaTestThree(dec.getLat(),dec.getLon());
    }

    public String areaFour(Dec dec){
        return areaTestFour(dec.getLat(),dec.getLon());
    }




    public String regionOne(Dec dec){
        return regionTestOne(dec.getCity());
    }

    @Override
    public String regionTwo(Dec dec) {
        return regionTestTwo(dec.getCity());
    }

    @Override
    public String regionThree(Dec dec) {
        return regionTestThree(dec.getCity());
    }

    @Override
    public String regionFour(Dec dec) {
        return regionTestFour(dec.getCity());
    }


    public String regionTestOne(String city){
        if("北京".equals(city)||"天津".equals(city)||"河北".equals(city)||"山西".equals(city)||"内蒙古".equals(city)){
            return "华北";
        }else if("河南".equals(city)||"湖北".equals(city)||"湖南".equals(city)){
            return "华中";
        }else if("广东".equals(city)||"广西".equals(city)||"海南".equals(city)){
            return "华南";
        }else if("上海".equals(city)||"江苏".equals(city)||"浙江".equals(city)||"安徽".equals(city)||"福建".equals(city)
                || "江西".equals(city)||"山东".equals(city)||"台湾".equals(city)){
            return "华东";
        }
        return "";
    }

    public String regionTestTwo(String city){
        if("北京".equals(city)||"天津".equals(city)||"河北".equals(city)||"山西".equals(city)||"内蒙古".equals(city)){
            return "华北";
        }else if("河南".equals(city)||"湖北".equals(city)||"湖南".equals(city)){
            return "华中";
        }else if("广东".equals(city)||"广西".equals(city)||"海南".equals(city)){
            return "华南";
        }else if("上海".equals(city)||"江苏".equals(city)||"浙江".equals(city)||"安徽".equals(city)||"福建".equals(city)
                || "江西".equals(city)||"山东".equals(city)||"台湾".equals(city)){
            return "华东";
        }
        return "";
    }

    public String regionTestThree(String city){
        if("北京".equals(city)||"天津".equals(city)||"河北".equals(city)||"山西".equals(city)||"内蒙古".equals(city)){
            return "华北";
        }else if("河南".equals(city)||"湖北".equals(city)||"湖南".equals(city)){
            return "华中";
        }else if("广东".equals(city)||"广西".equals(city)||"海南".equals(city)){
            return "华南";
        }else if("上海".equals(city)||"江苏".equals(city)||"浙江".equals(city)||"安徽".equals(city)||"福建".equals(city)
                || "江西".equals(city)||"山东".equals(city)||"台湾".equals(city)){
            return "华东";
        }
        return "";
    }

    public String regionTestFour(String city){
        if("北京".equals(city)||"天津".equals(city)||"河北".equals(city)||"山西".equals(city)||"内蒙古".equals(city)){
            return "华北";
        }else if("河南".equals(city)||"湖北".equals(city)||"湖南".equals(city)){
            return "华中";
        }else if("广东".equals(city)||"广西".equals(city)||"海南".equals(city)){
            return "华南";
        }else if("上海".equals(city)||"江苏".equals(city)||"浙江".equals(city)||"安徽".equals(city)||"福建".equals(city)
                || "江西".equals(city)||"山东".equals(city)||"台湾".equals(city)){
            return "华东";
        }
        return "";
    }


    public String areaTestOne(String lat,String lon){
        Double finalLat = Double.valueOf(lat);
        Double finalLon = Double.valueOf(lon);

        if(finalLat>=39.4 && finalLat<=41.6 && finalLon>=115.7&& finalLon<=117.4){
            return "北京";
        }else if (finalLat>=24.7 && finalLat<=30.1 && finalLon>=108.8&& finalLon<=114.2){
            return "湖南";
        }else if (finalLat>=38.34 && finalLat<=40.15 && finalLon>=116.43&& finalLon<=118.04){
            return "天津";
        }else if (finalLat>=29.05 && finalLat<=33.20 && finalLon>=108.21&& finalLon<=116.07){
            return "湖北";
        }else if (finalLat>=30.40 && finalLat<=31.53 && finalLon>=120.51&& finalLon<=122.12){
            return "上海";
        }else if (finalLat>=20.12 && finalLat<=25.31 && finalLon>=109.17&& finalLon<=117.20){
            return "广东";
        }else if (finalLat>=28.10 && finalLat<=32.13 && finalLon>=105.17&& finalLon<=110.11){
            return "重庆";
        }else if (finalLat>=18.10 && finalLat<=20.10 && finalLon>=108.37&& finalLon<=119.53){
            return "海南";
        }else if (finalLat>=36.01 && finalLat<=42.37 && finalLon>=113.04&& finalLon<=119.53){
            return "河北";
        }else if (finalLat>=26.03 && finalLat<=34.19 && finalLon>=98.21&& finalLon<=108.31){
            return "四川";
        }else if (finalLat>=34.36 && finalLat<=40.44 && finalLon>=110.15&& finalLon<=114.32){
            return "山西";
        }else if (finalLat>=24.37 && finalLat<=29.13 && finalLon>=103.36&& finalLon<=109.35){
            return "贵州";
        }else if (finalLat>=38.43 && finalLat<=43.26 && finalLon>=118.53&& finalLon<=125.46){
            return "辽宁";
        }else if (finalLat>=21.08 && finalLat<=29.15 && finalLon>=97.31&& finalLon<=106.12){
            return "云南";
        }else if (finalLat>=40.52 && finalLat<=46.18 && finalLon>=121.38&& finalLon<=131.19){
            return "吉林";
        }else if (finalLat>=31.42 && finalLat<=39.35 && finalLon>=105.29&& finalLon<=111.15){
            return "陕西";
        }else if (finalLat>=43.25 && finalLat<=53.33 && finalLon>=121.11&& finalLon<=135.05){
            return "黑龙江";
        }else if (finalLat>=32.11 && finalLat<=42.57 && finalLon>=92.13&& finalLon<=108.46){
            return "甘肃";
        }else if (finalLat>=30.45 && finalLat<=35.20 && finalLon>=116.18&& finalLon<=121.57){
            return "江苏";
        }else if (finalLat>=31.32 && finalLat<=39.20 && finalLon>=59.24&& finalLon<=103.04){
            return "青海";
        }else if (finalLat>=27.02 && finalLat<=31.11 && finalLon>=118.01&& finalLon<=123.10){
            return "浙江";
        }else if (finalLat>=29.41 && finalLat<=34.38 && finalLon>=114.54&& finalLon<=119.37){
            return "安徽";
        }else if (finalLat>=26.44 && finalLat<=36.32 && finalLon>=78.25&& finalLon<=99.06){
            return "西藏";
        }else if (finalLat>=23.30 && finalLat<=28.22 && finalLon>=115.7&& finalLon<=117.4){
            return "福建";
        }else if (finalLat>=37.30 && finalLat<=53.20 && finalLon>=97.10&& finalLon<=126.02){
            return "内蒙古";
        }else if (finalLat>=24.29 && finalLat<=30.04 && finalLon>=113.34&& finalLon<=118.28){
            return "江西";
        }else if (finalLat>=20.54 && finalLat<=26.23 && finalLon>=104.29&& finalLon<=112.04){
            return "广西";
        }else if (finalLat>=34.22 && finalLat<=38.23 && finalLon>=104.17&& finalLon<=107.39){
            return "山东";
        }else if (finalLat>=35.14 && finalLat<=39.23 && finalLon>=104.17&& finalLon<=107.39){
            return "宁夏";
        }else if (finalLat>=31.23 && finalLat<=36.22 && finalLon>=110.21&& finalLon<=116.39){
            return "河南";
        }else if (finalLat>=34.22 && finalLat<=49.33 && finalLon>=73.41&& finalLon<=96.18){
            return "新疆";
        }
        return "";
    }

    public String areaTestTwo(String lat,String lon){
        Double finalLat = Double.valueOf(lat);
        Double finalLon = Double.valueOf(lon);

        if(finalLat>=39.4 && finalLat<=41.6 && finalLon>=115.7&& finalLon<=117.4){
            return "北京";
        }else if (finalLat>=24.7 && finalLat<=30.1 && finalLon>=108.8&& finalLon<=114.2){
            return "湖南";
        }else if (finalLat>=38.34 && finalLat<=40.15 && finalLon>=116.43&& finalLon<=118.04){
            return "天津";
        }else if (finalLat>=29.05 && finalLat<=33.20 && finalLon>=108.21&& finalLon<=116.07){
            return "湖北";
        }else if (finalLat>=30.40 && finalLat<=31.53 && finalLon>=120.51&& finalLon<=122.12){
            return "上海";
        }else if (finalLat>=20.12 && finalLat<=25.31 && finalLon>=109.17&& finalLon<=117.20){
            return "广东";
        }else if (finalLat>=28.10 && finalLat<=32.13 && finalLon>=105.17&& finalLon<=110.11){
            return "重庆";
        }else if (finalLat>=18.10 && finalLat<=20.10 && finalLon>=108.37&& finalLon<=119.53){
            return "海南";
        }else if (finalLat>=36.01 && finalLat<=42.37 && finalLon>=113.04&& finalLon<=119.53){
            return "河北";
        }else if (finalLat>=26.03 && finalLat<=34.19 && finalLon>=98.21&& finalLon<=108.31){
            return "四川";
        }else if (finalLat>=34.36 && finalLat<=40.44 && finalLon>=110.15&& finalLon<=114.32){
            return "山西";
        }else if (finalLat>=24.37 && finalLat<=29.13 && finalLon>=103.36&& finalLon<=109.35){
            return "贵州";
        }else if (finalLat>=38.43 && finalLat<=43.26 && finalLon>=118.53&& finalLon<=125.46){
            return "辽宁";
        }else if (finalLat>=21.08 && finalLat<=29.15 && finalLon>=97.31&& finalLon<=106.12){
            return "云南";
        }else if (finalLat>=40.52 && finalLat<=46.18 && finalLon>=121.38&& finalLon<=131.19){
            return "吉林";
        }else if (finalLat>=31.42 && finalLat<=39.35 && finalLon>=105.29&& finalLon<=111.15){
            return "陕西";
        }else if (finalLat>=43.25 && finalLat<=53.33 && finalLon>=121.11&& finalLon<=135.05){
            return "黑龙江";
        }else if (finalLat>=32.11 && finalLat<=42.57 && finalLon>=92.13&& finalLon<=108.46){
            return "甘肃";
        }else if (finalLat>=30.45 && finalLat<=35.20 && finalLon>=116.18&& finalLon<=121.57){
            return "江苏";
        }else if (finalLat>=31.32 && finalLat<=39.20 && finalLon>=59.24&& finalLon<=103.04){
            return "青海";
        }else if (finalLat>=27.02 && finalLat<=31.11 && finalLon>=118.01&& finalLon<=123.10){
            return "浙江";
        }else if (finalLat>=29.41 && finalLat<=34.38 && finalLon>=114.54&& finalLon<=119.37){
            return "安徽";
        }else if (finalLat>=26.44 && finalLat<=36.32 && finalLon>=78.25&& finalLon<=99.06){
            return "西藏";
        }else if (finalLat>=23.30 && finalLat<=28.22 && finalLon>=115.7&& finalLon<=117.4){
            return "福建";
        }else if (finalLat>=37.30 && finalLat<=53.20 && finalLon>=97.10&& finalLon<=126.02){
            return "内蒙古";
        }else if (finalLat>=24.29 && finalLat<=30.04 && finalLon>=113.34&& finalLon<=118.28){
            return "江西";
        }else if (finalLat>=20.54 && finalLat<=26.23 && finalLon>=104.29&& finalLon<=112.04){
            return "广西";
        }else if (finalLat>=34.22 && finalLat<=38.23 && finalLon>=104.17&& finalLon<=107.39){
            return "山东";
        }else if (finalLat>=35.14 && finalLat<=39.23 && finalLon>=104.17&& finalLon<=107.39){
            return "宁夏";
        }else if (finalLat>=31.23 && finalLat<=36.22 && finalLon>=110.21&& finalLon<=116.39){
            return "河南";
        }else if (finalLat>=34.22 && finalLat<=49.33 && finalLon>=73.41&& finalLon<=96.18){
            return "新疆";
        }
        return "";
    }

    public String areaTestThree(String lat,String lon){
        Double finalLat = Double.valueOf(lat);
        Double finalLon = Double.valueOf(lon);

        if(finalLat>=39.4 && finalLat<=41.6 && finalLon>=115.7&& finalLon<=117.4){
            return "北京";
        }else if (finalLat>=24.7 && finalLat<=30.1 && finalLon>=108.8&& finalLon<=114.2){
            return "湖南";
        }else if (finalLat>=38.34 && finalLat<=40.15 && finalLon>=116.43&& finalLon<=118.04){
            return "天津";
        }else if (finalLat>=29.05 && finalLat<=33.20 && finalLon>=108.21&& finalLon<=116.07){
            return "湖北";
        }else if (finalLat>=30.40 && finalLat<=31.53 && finalLon>=120.51&& finalLon<=122.12){
            return "上海";
        }else if (finalLat>=20.12 && finalLat<=25.31 && finalLon>=109.17&& finalLon<=117.20){
            return "广东";
        }else if (finalLat>=28.10 && finalLat<=32.13 && finalLon>=105.17&& finalLon<=110.11){
            return "重庆";
        }else if (finalLat>=18.10 && finalLat<=20.10 && finalLon>=108.37&& finalLon<=119.53){
            return "海南";
        }else if (finalLat>=36.01 && finalLat<=42.37 && finalLon>=113.04&& finalLon<=119.53){
            return "河北";
        }else if (finalLat>=26.03 && finalLat<=34.19 && finalLon>=98.21&& finalLon<=108.31){
            return "四川";
        }else if (finalLat>=34.36 && finalLat<=40.44 && finalLon>=110.15&& finalLon<=114.32){
            return "山西";
        }else if (finalLat>=24.37 && finalLat<=29.13 && finalLon>=103.36&& finalLon<=109.35){
            return "贵州";
        }else if (finalLat>=38.43 && finalLat<=43.26 && finalLon>=118.53&& finalLon<=125.46){
            return "辽宁";
        }else if (finalLat>=21.08 && finalLat<=29.15 && finalLon>=97.31&& finalLon<=106.12){
            return "云南";
        }else if (finalLat>=40.52 && finalLat<=46.18 && finalLon>=121.38&& finalLon<=131.19){
            return "吉林";
        }else if (finalLat>=31.42 && finalLat<=39.35 && finalLon>=105.29&& finalLon<=111.15){
            return "陕西";
        }else if (finalLat>=43.25 && finalLat<=53.33 && finalLon>=121.11&& finalLon<=135.05){
            return "黑龙江";
        }else if (finalLat>=32.11 && finalLat<=42.57 && finalLon>=92.13&& finalLon<=108.46){
            return "甘肃";
        }else if (finalLat>=30.45 && finalLat<=35.20 && finalLon>=116.18&& finalLon<=121.57){
            return "江苏";
        }else if (finalLat>=31.32 && finalLat<=39.20 && finalLon>=59.24&& finalLon<=103.04){
            return "青海";
        }else if (finalLat>=27.02 && finalLat<=31.11 && finalLon>=118.01&& finalLon<=123.10){
            return "浙江";
        }else if (finalLat>=29.41 && finalLat<=34.38 && finalLon>=114.54&& finalLon<=119.37){
            return "安徽";
        }else if (finalLat>=26.44 && finalLat<=36.32 && finalLon>=78.25&& finalLon<=99.06){
            return "西藏";
        }else if (finalLat>=23.30 && finalLat<=28.22 && finalLon>=115.7&& finalLon<=117.4){
            return "福建";
        }else if (finalLat>=37.30 && finalLat<=53.20 && finalLon>=97.10&& finalLon<=126.02){
            return "内蒙古";
        }else if (finalLat>=24.29 && finalLat<=30.04 && finalLon>=113.34&& finalLon<=118.28){
            return "江西";
        }else if (finalLat>=20.54 && finalLat<=26.23 && finalLon>=104.29&& finalLon<=112.04){
            return "广西";
        }else if (finalLat>=34.22 && finalLat<=38.23 && finalLon>=104.17&& finalLon<=107.39){
            return "山东";
        }else if (finalLat>=35.14 && finalLat<=39.23 && finalLon>=104.17&& finalLon<=107.39){
            return "宁夏";
        }else if (finalLat>=31.23 && finalLat<=36.22 && finalLon>=110.21&& finalLon<=116.39){
            return "河南";
        }else if (finalLat>=34.22 && finalLat<=49.33 && finalLon>=73.41&& finalLon<=96.18){
            return "新疆";
        }
        return "";
    }

    public String areaTestFour(String lat,String lon){
        Double finalLat = Double.valueOf(lat);
        Double finalLon = Double.valueOf(lon);

        if(finalLat>=39.4 && finalLat<=41.6 && finalLon>=115.7&& finalLon<=117.4){
            return "北京";
        }else if (finalLat>=24.7 && finalLat<=30.1 && finalLon>=108.8&& finalLon<=114.2){
            return "湖南";
        }else if (finalLat>=38.34 && finalLat<=40.15 && finalLon>=116.43&& finalLon<=118.04){
            return "天津";
        }else if (finalLat>=29.05 && finalLat<=33.20 && finalLon>=108.21&& finalLon<=116.07){
            return "湖北";
        }else if (finalLat>=30.40 && finalLat<=31.53 && finalLon>=120.51&& finalLon<=122.12){
            return "上海";
        }else if (finalLat>=20.12 && finalLat<=25.31 && finalLon>=109.17&& finalLon<=117.20){
            return "广东";
        }else if (finalLat>=28.10 && finalLat<=32.13 && finalLon>=105.17&& finalLon<=110.11){
            return "重庆";
        }else if (finalLat>=18.10 && finalLat<=20.10 && finalLon>=108.37&& finalLon<=119.53){
            return "海南";
        }else if (finalLat>=36.01 && finalLat<=42.37 && finalLon>=113.04&& finalLon<=119.53){
            return "河北";
        }else if (finalLat>=26.03 && finalLat<=34.19 && finalLon>=98.21&& finalLon<=108.31){
            return "四川";
        }else if (finalLat>=34.36 && finalLat<=40.44 && finalLon>=110.15&& finalLon<=114.32){
            return "山西";
        }else if (finalLat>=24.37 && finalLat<=29.13 && finalLon>=103.36&& finalLon<=109.35){
            return "贵州";
        }else if (finalLat>=38.43 && finalLat<=43.26 && finalLon>=118.53&& finalLon<=125.46){
            return "辽宁";
        }else if (finalLat>=21.08 && finalLat<=29.15 && finalLon>=97.31&& finalLon<=106.12){
            return "云南";
        }else if (finalLat>=40.52 && finalLat<=46.18 && finalLon>=121.38&& finalLon<=131.19){
            return "吉林";
        }else if (finalLat>=31.42 && finalLat<=39.35 && finalLon>=105.29&& finalLon<=111.15){
            return "陕西";
        }else if (finalLat>=43.25 && finalLat<=53.33 && finalLon>=121.11&& finalLon<=135.05){
            return "黑龙江";
        }else if (finalLat>=32.11 && finalLat<=42.57 && finalLon>=92.13&& finalLon<=108.46){
            return "甘肃";
        }else if (finalLat>=30.45 && finalLat<=35.20 && finalLon>=116.18&& finalLon<=121.57){
            return "江苏";
        }else if (finalLat>=31.32 && finalLat<=39.20 && finalLon>=59.24&& finalLon<=103.04){
            return "青海";
        }else if (finalLat>=27.02 && finalLat<=31.11 && finalLon>=118.01&& finalLon<=123.10){
            return "浙江";
        }else if (finalLat>=29.41 && finalLat<=34.38 && finalLon>=114.54&& finalLon<=119.37){
            return "安徽";
        }else if (finalLat>=26.44 && finalLat<=36.32 && finalLon>=78.25&& finalLon<=99.06){
            return "西藏";
        }else if (finalLat>=23.30 && finalLat<=28.22 && finalLon>=115.7&& finalLon<=117.4){
            return "福建";
        }else if (finalLat>=37.30 && finalLat<=53.20 && finalLon>=97.10&& finalLon<=126.02){
            return "内蒙古";
        }else if (finalLat>=24.29 && finalLat<=30.04 && finalLon>=113.34&& finalLon<=118.28){
            return "江西";
        }else if (finalLat>=20.54 && finalLat<=26.23 && finalLon>=104.29&& finalLon<=112.04){
            return "广西";
        }else if (finalLat>=34.22 && finalLat<=38.23 && finalLon>=104.17&& finalLon<=107.39){
            return "山东";
        }else if (finalLat>=35.14 && finalLat<=39.23 && finalLon>=104.17&& finalLon<=107.39){
            return "宁夏";
        }else if (finalLat>=31.23 && finalLat<=36.22 && finalLon>=110.21&& finalLon<=116.39){
            return "河南";
        }else if (finalLat>=34.22 && finalLat<=49.33 && finalLon>=73.41&& finalLon<=96.18){
            return "新疆";
        }
        return "";
    }

    public double excuteTwo(Dec dec) {
        final double pm_2_5  = excuteTwo(AqiDictionaryUtil.pm2_5Map, dec.getPm25());
        //  log.info("算出的 pm2.5 ======>{}",pm_2_5);
        final double co = excuteTwo(AqiDictionaryUtil.coMap,dec.getCo());
        //  log.info("算出的 co ========>{}",co);
        final double no2 = excuteTwo(AqiDictionaryUtil.no2Map, dec.getNo2());

        //   log.info("算出的 no2 ========>{}",no2);
        final double o3 = excuteTwo(AqiDictionaryUtil.o3Map, dec.getO3());

        //   log.info("算出的 o3 ========>{}",o3);
        final double so2 = excuteTwo(AqiDictionaryUtil.so2Map, dec.getSo2());

        //   log.info("算出的 so2 ========>{}",so2);

        final double maxone = Math.max(pm_2_5, co);
        final double maxtwo = Math.max(no2, o3);
        final double maxthree = Math.max(maxone, maxtwo);
        final double max = Math.max(maxthree, so2);

        return max;

    }
    @Override
    public double excuteMax(Dec dec){

        final double pm_2_5  = excute(AqiDictionaryUtil.pm2_5Map, dec.getPm25());
        //  log.info("算出的 pm2.5 ======>{}",pm_2_5);
        final double co = excute(AqiDictionaryUtil.coMap,dec.getCo());
        //  log.info("算出的 co ========>{}",co);
        final double no2 = excute(AqiDictionaryUtil.no2Map, dec.getNo2());

        //   log.info("算出的 no2 ========>{}",no2);
        final double o3 = excute(AqiDictionaryUtil.o3Map, dec.getO3());

        //   log.info("算出的 o3 ========>{}",o3);
        final double so2 = excute(AqiDictionaryUtil.so2Map, dec.getSo2());

        //   log.info("算出的 so2 ========>{}",so2);

        final double maxone = Math.max(pm_2_5, co);
        final double maxtwo = Math.max(no2, o3);
        final double maxthree = Math.max(maxone, maxtwo);
        final double max = Math.max(maxthree, so2);

        return max;
    }


    @Override
    public double excuteFive(Dec dec){

        final double pm_2_5  = excuteFive(AqiDictionaryUtil.pm2_5Map, dec.getPm25());
        //  log.info("算出的 pm2.5 ======>{}",pm_2_5);
        final double co = excuteFive(AqiDictionaryUtil.coMap,dec.getCo());
        //  log.info("算出的 co ========>{}",co);
        final double no2 = excuteFive(AqiDictionaryUtil.no2Map, dec.getNo2());

        //   log.info("算出的 no2 ========>{}",no2);
        final double o3 = excuteFive(AqiDictionaryUtil.o3Map, dec.getO3());

        //   log.info("算出的 o3 ========>{}",o3);
        final double so2 = excuteFive(AqiDictionaryUtil.so2Map, dec.getSo2());

        //   log.info("算出的 so2 ========>{}",so2);

        final double maxone = Math.max(pm_2_5, co);
        final double maxtwo = Math.max(no2, o3);
        final double maxthree = Math.max(maxone, maxtwo);
        final double max = Math.max(maxthree, so2);

        return max;
    }
    @Override
    public double excuteSix(Dec dec){

        final double pm_2_5  = excuteSix(AqiDictionaryUtil.pm2_5Map, dec.getPm25());
        //  log.info("算出的 pm2.5 ======>{}",pm_2_5);
        final double co = excuteSix(AqiDictionaryUtil.coMap,dec.getCo());
        //  log.info("算出的 co ========>{}",co);
        final double no2 = excuteSix(AqiDictionaryUtil.no2Map, dec.getNo2());

        //   log.info("算出的 no2 ========>{}",no2);
        final double o3 = excuteSix(AqiDictionaryUtil.o3Map, dec.getO3());

        //   log.info("算出的 o3 ========>{}",o3);
        final double so2 = excuteSix(AqiDictionaryUtil.so2Map, dec.getSo2());

        //   log.info("算出的 so2 ========>{}",so2);

        final double maxone = Math.max(pm_2_5, co);
        final double maxtwo = Math.max(no2, o3);
        final double maxthree = Math.max(maxone, maxtwo);
        final double max = Math.max(maxthree, so2);

        return max;
    }
    @Override
    public double excuteSeven(Dec dec){

        final double pm_2_5  = excuteSeven(AqiDictionaryUtil.pm2_5Map, dec.getPm25());
        //  log.info("算出的 pm2.5 ======>{}",pm_2_5);
        final double co = excuteSeven(AqiDictionaryUtil.coMap,dec.getCo());
        //  log.info("算出的 co ========>{}",co);
        final double no2 = excuteSeven(AqiDictionaryUtil.no2Map, dec.getNo2());

        //   log.info("算出的 no2 ========>{}",no2);
        final double o3 = excuteSeven(AqiDictionaryUtil.o3Map, dec.getO3());

        //   log.info("算出的 o3 ========>{}",o3);
        final double so2 = excuteSeven(AqiDictionaryUtil.so2Map, dec.getSo2());

        //   log.info("算出的 so2 ========>{}",so2);

        final double maxone = Math.max(pm_2_5, co);
        final double maxtwo = Math.max(no2, o3);
        final double maxthree = Math.max(maxone, maxtwo);
        final double max = Math.max(maxthree, so2);

        return max;
    }
    @Override
    public double excuteEight(Dec dec){

        final double pm_2_5  = excuteEight(AqiDictionaryUtil.pm2_5Map, dec.getPm25());
        //  log.info("算出的 pm2.5 ======>{}",pm_2_5);
        final double co = excuteEight(AqiDictionaryUtil.coMap,dec.getCo());
        //  log.info("算出的 co ========>{}",co);
        final double no2 = excuteEight(AqiDictionaryUtil.no2Map, dec.getNo2());

        //   log.info("算出的 no2 ========>{}",no2);
        final double o3 = excuteEight(AqiDictionaryUtil.o3Map, dec.getO3());

        //   log.info("算出的 o3 ========>{}",o3);
        final double so2 = excuteEight(AqiDictionaryUtil.so2Map, dec.getSo2());

        //   log.info("算出的 so2 ========>{}",so2);

        final double maxone = Math.max(pm_2_5, co);
        final double maxtwo = Math.max(no2, o3);
        final double maxthree = Math.max(maxone, maxtwo);
        final double max = Math.max(maxthree, so2);

        return max;
    }
    @Override
    public double excuteNight(Dec dec){

        final double pm_2_5  = excuteNight(AqiDictionaryUtil.pm2_5Map, dec.getPm25());
        //  log.info("算出的 pm2.5 ======>{}",pm_2_5);
        final double co = excuteNight(AqiDictionaryUtil.coMap,dec.getCo());
        //  log.info("算出的 co ========>{}",co);
        final double no2 = excuteNight(AqiDictionaryUtil.no2Map, dec.getNo2());

        //   log.info("算出的 no2 ========>{}",no2);
        final double o3 = excuteNight(AqiDictionaryUtil.o3Map, dec.getO3());

        //   log.info("算出的 o3 ========>{}",o3);
        final double so2 = excuteNight(AqiDictionaryUtil.so2Map, dec.getSo2());

        //   log.info("算出的 so2 ========>{}",so2);

        final double maxone = Math.max(pm_2_5, co);
        final double maxtwo = Math.max(no2, o3);
        final double maxthree = Math.max(maxone, maxtwo);
        final double max = Math.max(maxthree, so2);

        return max;
    }
    @Override
    public double excuteTen(Dec dec){

        final double pm_2_5  = excuteTen(AqiDictionaryUtil.pm2_5Map, dec.getPm25());
        //  log.info("算出的 pm2.5 ======>{}",pm_2_5);
        final double co = excuteTen(AqiDictionaryUtil.coMap,dec.getCo());
        //  log.info("算出的 co ========>{}",co);
        final double no2 = excuteTen(AqiDictionaryUtil.no2Map, dec.getNo2());

        //   log.info("算出的 no2 ========>{}",no2);
        final double o3 = excuteTen(AqiDictionaryUtil.o3Map, dec.getO3());

        //   log.info("算出的 o3 ========>{}",o3);
        final double so2 = excuteTen(AqiDictionaryUtil.so2Map, dec.getSo2());

        //   log.info("算出的 so2 ========>{}",so2);

        final double maxone = Math.max(pm_2_5, co);
        final double maxtwo = Math.max(no2, o3);
        final double maxthree = Math.max(maxone, maxtwo);
        final double max = Math.max(maxthree, so2);

        return max;
    }

    /*
    * 计算整个aqi 拿到最大值
    * */






    public double excuteThreee(Map<Integer,Integer> map,String trValue){

        final Double value = Double.valueOf(trValue);

        int aqilow = 1;
        int aqihigh = 2;

        int indexlow = 1;
        int indexhigh = 2;


        if(value < map.get(50)){
            aqilow = 0;
            aqihigh = 50;
            indexlow = 0;
            indexhigh = map.get(50);

        }
        if(value>=map.get(50) && value< map.get(100)){
            aqilow = 50;
            aqihigh = 100;
            indexlow = map.get(50);
            indexhigh = map.get(100);
        }
        if(value>=map.get(100) && value< map.get(150)){
            aqilow = 100;
            aqihigh = 150;
            indexlow = map.get(100);
            indexhigh = map.get(150);
        }
        if(value>=map.get(150) && value< map.get(200)){
            aqilow = 150;
            aqihigh = 200;
            indexlow = map.get(150);
            indexhigh = map.get(200);
        }

        if(value>=map.get(200) && value<map.get(300)){
            aqilow = 200;
            aqihigh = 300;
            indexlow = map.get(200);
            indexhigh = map.get(300);
        }
        if(value>=map.get(300) && value< map.get(400)){
            aqilow = 300;
            aqihigh = 400;
            indexlow = map.get(300);
            indexhigh = map.get(400);
        }
        if(value>=map.get(400) && value< map.get(500)){
            aqilow = 400;
            aqihigh = 500;
            indexlow = map.get(400);
            indexhigh = map.get(500);
        }


        double returnValue = ((aqihigh-aqilow)/(indexhigh-indexlow))*(value -indexlow)+aqilow;

        return returnValue;

    }
    public double excutefour(Map<Integer,Integer> map,String trValue){

        final Double value = Double.valueOf(trValue);

        int aqilow = 1;
        int aqihigh = 2;

        int indexlow = 1;
        int indexhigh = 2;


        if(value < map.get(50)){
            aqilow = 0;
            aqihigh = 50;
            indexlow = 0;
            indexhigh = map.get(50);

        }
        if(value>=map.get(50) && value< map.get(100)){
            aqilow = 50;
            aqihigh = 100;
            indexlow = map.get(50);
            indexhigh = map.get(100);
        }
        if(value>=map.get(100) && value< map.get(150)){
            aqilow = 100;
            aqihigh = 150;
            indexlow = map.get(100);
            indexhigh = map.get(150);
        }
        if(value>=map.get(150) && value< map.get(200)){
            aqilow = 150;
            aqihigh = 200;
            indexlow = map.get(150);
            indexhigh = map.get(200);
        }

        if(value>=map.get(200) && value<map.get(300)){
            aqilow = 200;
            aqihigh = 300;
            indexlow = map.get(200);
            indexhigh = map.get(300);
        }
        if(value>=map.get(300) && value< map.get(400)){
            aqilow = 300;
            aqihigh = 400;
            indexlow = map.get(300);
            indexhigh = map.get(400);
        }
        if(value>=map.get(400) && value< map.get(500)){
            aqilow = 400;
            aqihigh = 500;
            indexlow = map.get(400);
            indexhigh = map.get(500);
        }


        double returnValue = ((aqihigh-aqilow)/(indexhigh-indexlow))*(value -indexlow)+aqilow;

        return returnValue;

    }
    public double excute(Map<Integer,Integer> map,String trValue){

        final Double value = Double.valueOf(trValue);

        int aqilow = 1;
        int aqihigh = 2;

        int indexlow = 1;
        int indexhigh = 2;


        if(value < map.get(50)){
            aqilow = 0;
            aqihigh = 50;
            indexlow = 0;
            indexhigh = map.get(50);

        }
        if(value>=map.get(50) && value< map.get(100)){
            aqilow = 50;
            aqihigh = 100;
            indexlow = map.get(50);
            indexhigh = map.get(100);
        }
        if(value>=map.get(100) && value< map.get(150)){
            aqilow = 100;
            aqihigh = 150;
            indexlow = map.get(100);
            indexhigh = map.get(150);
        }
        if(value>=map.get(150) && value< map.get(200)){
            aqilow = 150;
            aqihigh = 200;
            indexlow = map.get(150);
            indexhigh = map.get(200);
        }

        if(value>=map.get(200) && value<map.get(300)){
            aqilow = 200;
            aqihigh = 300;
            indexlow = map.get(200);
            indexhigh = map.get(300);
        }
        if(value>=map.get(300) && value< map.get(400)){
            aqilow = 300;
            aqihigh = 400;
            indexlow = map.get(300);
            indexhigh = map.get(400);
        }
        if(value>=map.get(400) && value< map.get(500)){
            aqilow = 400;
            aqihigh = 500;
            indexlow = map.get(400);
            indexhigh = map.get(500);
        }


        double returnValue = ((aqihigh-aqilow)/(indexhigh-indexlow))*(value -indexlow)+aqilow;

        return returnValue;

    }
    public double excuteTwo(Map<Integer,Integer> map,String trValue){

        final Double value = Double.valueOf(trValue);

        int aqilow = 1;
        int aqihigh = 2;

        int indexlow = 1;
        int indexhigh = 2;


        if(value < map.get(50)){
            aqilow = 0;
            aqihigh = 50;
            indexlow = 0;
            indexhigh = map.get(50);

        }
        if(value>=map.get(50) && value< map.get(100)){
            aqilow = 50;
            aqihigh = 100;
            indexlow = map.get(50);
            indexhigh = map.get(100);
        }
        if(value>=map.get(100) && value< map.get(150)){
            aqilow = 100;
            aqihigh = 150;
            indexlow = map.get(100);
            indexhigh = map.get(150);
        }
        if(value>=map.get(150) && value< map.get(200)){
            aqilow = 150;
            aqihigh = 200;
            indexlow = map.get(150);
            indexhigh = map.get(200);
        }

        if(value>=map.get(200) && value<map.get(300)){
            aqilow = 200;
            aqihigh = 300;
            indexlow = map.get(200);
            indexhigh = map.get(300);
        }
        if(value>=map.get(300) && value< map.get(400)){
            aqilow = 300;
            aqihigh = 400;
            indexlow = map.get(300);
            indexhigh = map.get(400);
        }
        if(value>=map.get(400) && value< map.get(500)){
            aqilow = 400;
            aqihigh = 500;
            indexlow = map.get(400);
            indexhigh = map.get(500);
        }


        double returnValue = ((aqihigh-aqilow)/(indexhigh-indexlow))*(value -indexlow)+aqilow;

        return returnValue;

    }

    public double excuteFive(Map<Integer,Integer> map,String trValue){

        final Double value = Double.valueOf(trValue);

        int aqilow = 1;
        int aqihigh = 2;

        int indexlow = 1;
        int indexhigh = 2;


        if(value < map.get(50)){
            aqilow = 0;
            aqihigh = 50;
            indexlow = 0;
            indexhigh = map.get(50);

        }
        if(value>=map.get(50) && value< map.get(100)){
            aqilow = 50;
            aqihigh = 100;
            indexlow = map.get(50);
            indexhigh = map.get(100);
        }
        if(value>=map.get(100) && value< map.get(150)){
            aqilow = 100;
            aqihigh = 150;
            indexlow = map.get(100);
            indexhigh = map.get(150);
        }
        if(value>=map.get(150) && value< map.get(200)){
            aqilow = 150;
            aqihigh = 200;
            indexlow = map.get(150);
            indexhigh = map.get(200);
        }

        if(value>=map.get(200) && value<map.get(300)){
            aqilow = 200;
            aqihigh = 300;
            indexlow = map.get(200);
            indexhigh = map.get(300);
        }
        if(value>=map.get(300) && value< map.get(400)){
            aqilow = 300;
            aqihigh = 400;
            indexlow = map.get(300);
            indexhigh = map.get(400);
        }
        if(value>=map.get(400) && value< map.get(500)){
            aqilow = 400;
            aqihigh = 500;
            indexlow = map.get(400);
            indexhigh = map.get(500);
        }


        double returnValue = ((aqihigh-aqilow)/(indexhigh-indexlow))*(value -indexlow)+aqilow;

        return returnValue;

    }
    public double excuteSix(Map<Integer,Integer> map,String trValue){

        final Double value = Double.valueOf(trValue);

        int aqilow = 1;
        int aqihigh = 2;

        int indexlow = 1;
        int indexhigh = 2;


        if(value < map.get(50)){
            aqilow = 0;
            aqihigh = 50;
            indexlow = 0;
            indexhigh = map.get(50);

        }
        if(value>=map.get(50) && value< map.get(100)){
            aqilow = 50;
            aqihigh = 100;
            indexlow = map.get(50);
            indexhigh = map.get(100);
        }
        if(value>=map.get(100) && value< map.get(150)){
            aqilow = 100;
            aqihigh = 150;
            indexlow = map.get(100);
            indexhigh = map.get(150);
        }
        if(value>=map.get(150) && value< map.get(200)){
            aqilow = 150;
            aqihigh = 200;
            indexlow = map.get(150);
            indexhigh = map.get(200);
        }

        if(value>=map.get(200) && value<map.get(300)){
            aqilow = 200;
            aqihigh = 300;
            indexlow = map.get(200);
            indexhigh = map.get(300);
        }
        if(value>=map.get(300) && value< map.get(400)){
            aqilow = 300;
            aqihigh = 400;
            indexlow = map.get(300);
            indexhigh = map.get(400);
        }
        if(value>=map.get(400) && value< map.get(500)){
            aqilow = 400;
            aqihigh = 500;
            indexlow = map.get(400);
            indexhigh = map.get(500);
        }


        double returnValue = ((aqihigh-aqilow)/(indexhigh-indexlow))*(value -indexlow)+aqilow;

        return returnValue;

    }
    public double excuteSeven(Map<Integer,Integer> map,String trValue){

        final Double value = Double.valueOf(trValue);

        int aqilow = 1;
        int aqihigh = 2;

        int indexlow = 1;
        int indexhigh = 2;


        if(value < map.get(50)){
            aqilow = 0;
            aqihigh = 50;
            indexlow = 0;
            indexhigh = map.get(50);

        }
        if(value>=map.get(50) && value< map.get(100)){
            aqilow = 50;
            aqihigh = 100;
            indexlow = map.get(50);
            indexhigh = map.get(100);
        }
        if(value>=map.get(100) && value< map.get(150)){
            aqilow = 100;
            aqihigh = 150;
            indexlow = map.get(100);
            indexhigh = map.get(150);
        }
        if(value>=map.get(150) && value< map.get(200)){
            aqilow = 150;
            aqihigh = 200;
            indexlow = map.get(150);
            indexhigh = map.get(200);
        }

        if(value>=map.get(200) && value<map.get(300)){
            aqilow = 200;
            aqihigh = 300;
            indexlow = map.get(200);
            indexhigh = map.get(300);
        }
        if(value>=map.get(300) && value< map.get(400)){
            aqilow = 300;
            aqihigh = 400;
            indexlow = map.get(300);
            indexhigh = map.get(400);
        }
        if(value>=map.get(400) && value< map.get(500)){
            aqilow = 400;
            aqihigh = 500;
            indexlow = map.get(400);
            indexhigh = map.get(500);
        }


        double returnValue = ((aqihigh-aqilow)/(indexhigh-indexlow))*(value -indexlow)+aqilow;

        return returnValue;

    }
    public double excuteEight(Map<Integer,Integer> map,String trValue){

        final Double value = Double.valueOf(trValue);

        int aqilow = 1;
        int aqihigh = 2;

        int indexlow = 1;
        int indexhigh = 2;


        if(value < map.get(50)){
            aqilow = 0;
            aqihigh = 50;
            indexlow = 0;
            indexhigh = map.get(50);

        }
        if(value>=map.get(50) && value< map.get(100)){
            aqilow = 50;
            aqihigh = 100;
            indexlow = map.get(50);
            indexhigh = map.get(100);
        }
        if(value>=map.get(100) && value< map.get(150)){
            aqilow = 100;
            aqihigh = 150;
            indexlow = map.get(100);
            indexhigh = map.get(150);
        }
        if(value>=map.get(150) && value< map.get(200)){
            aqilow = 150;
            aqihigh = 200;
            indexlow = map.get(150);
            indexhigh = map.get(200);
        }

        if(value>=map.get(200) && value<map.get(300)){
            aqilow = 200;
            aqihigh = 300;
            indexlow = map.get(200);
            indexhigh = map.get(300);
        }
        if(value>=map.get(300) && value< map.get(400)){
            aqilow = 300;
            aqihigh = 400;
            indexlow = map.get(300);
            indexhigh = map.get(400);
        }
        if(value>=map.get(400) && value< map.get(500)){
            aqilow = 400;
            aqihigh = 500;
            indexlow = map.get(400);
            indexhigh = map.get(500);
        }


        double returnValue = ((aqihigh-aqilow)/(indexhigh-indexlow))*(value -indexlow)+aqilow;

        return returnValue;

    }
    public double excuteNight(Map<Integer,Integer> map,String trValue){

        final Double value = Double.valueOf(trValue);

        int aqilow = 1;
        int aqihigh = 2;

        int indexlow = 1;
        int indexhigh = 2;


        if(value < map.get(50)){
            aqilow = 0;
            aqihigh = 50;
            indexlow = 0;
            indexhigh = map.get(50);

        }
        if(value>=map.get(50) && value< map.get(100)){
            aqilow = 50;
            aqihigh = 100;
            indexlow = map.get(50);
            indexhigh = map.get(100);
        }
        if(value>=map.get(100) && value< map.get(150)){
            aqilow = 100;
            aqihigh = 150;
            indexlow = map.get(100);
            indexhigh = map.get(150);
        }
        if(value>=map.get(150) && value< map.get(200)){
            aqilow = 150;
            aqihigh = 200;
            indexlow = map.get(150);
            indexhigh = map.get(200);
        }

        if(value>=map.get(200) && value<map.get(300)){
            aqilow = 200;
            aqihigh = 300;
            indexlow = map.get(200);
            indexhigh = map.get(300);
        }
        if(value>=map.get(300) && value< map.get(400)){
            aqilow = 300;
            aqihigh = 400;
            indexlow = map.get(300);
            indexhigh = map.get(400);
        }
        if(value>=map.get(400) && value< map.get(500)){
            aqilow = 400;
            aqihigh = 500;
            indexlow = map.get(400);
            indexhigh = map.get(500);
        }


        double returnValue = ((aqihigh-aqilow)/(indexhigh-indexlow))*(value -indexlow)+aqilow;

        return returnValue;

    }
    public double excuteTen(Map<Integer,Integer> map,String trValue){

        final Double value = Double.valueOf(trValue);

        int aqilow = 1;
        int aqihigh = 2;

        int indexlow = 1;
        int indexhigh = 2;


        if(value < map.get(50)){
            aqilow = 0;
            aqihigh = 50;
            indexlow = 0;
            indexhigh = map.get(50);

        }
        if(value>=map.get(50) && value< map.get(100)){
            aqilow = 50;
            aqihigh = 100;
            indexlow = map.get(50);
            indexhigh = map.get(100);
        }
        if(value>=map.get(100) && value< map.get(150)){
            aqilow = 100;
            aqihigh = 150;
            indexlow = map.get(100);
            indexhigh = map.get(150);
        }
        if(value>=map.get(150) && value< map.get(200)){
            aqilow = 150;
            aqihigh = 200;
            indexlow = map.get(150);
            indexhigh = map.get(200);
        }

        if(value>=map.get(200) && value<map.get(300)){
            aqilow = 200;
            aqihigh = 300;
            indexlow = map.get(200);
            indexhigh = map.get(300);
        }
        if(value>=map.get(300) && value< map.get(400)){
            aqilow = 300;
            aqihigh = 400;
            indexlow = map.get(300);
            indexhigh = map.get(400);
        }
        if(value>=map.get(400) && value< map.get(500)){
            aqilow = 400;
            aqihigh = 500;
            indexlow = map.get(400);
            indexhigh = map.get(500);
        }


        double returnValue = ((aqihigh-aqilow)/(indexhigh-indexlow))*(value -indexlow)+aqilow;

        return returnValue;

    }


}
